home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
gwuada_9.zip
/
ADALIB2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-27
|
14KB
|
391 lines
/* liblist.c: translation of code generator read.stl*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "config.h"
#include "segment.h"
#include "slot.h"
#include "ifile.h"
#include "miscp.h"
#include "libfp.h"
static void load_library();
static void get_local_ref_maps(IFILE *, int);
static long get_cde_slots(IFILE *, Axq);
static void get_slot(IFILE *, char *);
static char *convert_date(char *);
static char *unit_name_name(char *);
static int is_subunit(char *);
static char *formatted_name(char *);
static char *formatted_stub(char *);
IFILE *LIBFILE;
#ifdef IBM_PC
/* on the PC, a chdir must be undone before program completes.
* changed_dir is set when directory changed.
*/
#endif
void main(int argc, char **argv)
{
int c;
int lib_opt = FALSE;
int errflg = 0;
extern int optind;
extern char *optarg;
char *libname,*fname;
char *t_name;
#ifdef IBM_PC
/* _outtext(" NYU Ada/Ed Librarian Version 1.11.1\n");
_outtext(" Copyright (C) 1985-1992 by New York University.");
*/
#endif
#ifndef IBM_PC
while((c = getopt(argc,argv,"l:"))!=EOF) {
#else
while((c = getopt(argc,argv,"L:l:"))!=EOF) {
if (isupper(c)) c = tolower(c);
#endif
switch(c) {
case 'l': /* specify library name */
lib_opt = TRUE;
libname = strjoin(optarg,"");
break;
case '?':
errflg++;
}
}
fname = (char *)0;
if (optind < argc) fname = argv[optind];
if (!lib_opt && fname == (char *)0) {
fname = getenv("ADALIB");
if (fname!= (char *)0) {
#ifdef IBM_PC
fprintf(stderr, "L");
#else
fprintf(stderr, "l");
#endif
fprintf(stderr,"ibrary defined by ADALIB: %s\n", fname);
}
}
if ((!lib_opt && fname == (char *)0) || errflg) {
fprintf(stderr, "Usage: adalib [-l library]\n");
exit(1);
}
if (!lib_opt) {
libname = emalloc(strlen(fname) + 1);
strcpy(libname, fname);
}
t_name = libset(libname);
LIBFILE = ifopen(LIBFILENAME, "", "r", 0);
load_library();
exit(0);
}
static void load_library() /*;load_library*/
{
/*
* retrieve information from LIBFILE
* Called only if lib_option and not newlib.
*/
int i, j, n, m, unumber, nodes, symbols;
int comp_status, unit_count, cur_level;
char *comp_date, *status_str, *uname, *aisname, *tmp_str;
char *main_string, *fmt_name, *fmt_date;
int is_main, empty_unit_slots, parent;
int ignore;
FILE *fout;
fout = fopen("avllib.$$$","w");
unit_count = getnum(LIBFILE,"lib-unit-count");
n = getnum(LIBFILE, "lib-n");
empty_unit_slots = getnum(LIBFILE, "lib-empty-slots");
tmp_str = getstr(LIBFILE,"lib-tmp-str");
for (i = 1; i <= unit_count; i++) {
uname = getstr(LIBFILE, "lib-unit-name");
unumber = getnum(LIBFILE, "lib-unit-number");
aisname = getstr(LIBFILE, "lib-ais-name");
comp_date = getstr(LIBFILE, "unit-date");
symbols = getnum(LIBFILE, "lib-symbols");
nodes = getnum(LIBFILE, "lib-nodes");
is_main = getnum(LIBFILE, "lib-is-main");
if (is_main) {
if (streq(unit_name_type(uname), "ma")) {
main_string = "(Interface)";
}
else {
main_string = " (Main) ";
}
}
else {
main_string = "";
}
comp_status = getnum(LIBFILE, "lib-status");
status_str = (comp_status) ? "Active " : "Obsolete";
fmt_date = convert_date(comp_date);
fmt_name = formatted_name(uname);
fprintf(fout,"%8s %11s %-15s %s\n",
status_str, main_string, fmt_date, fmt_name);
}
fprintf(fout,"\n");
n = getnum(LIBFILE, "lib-n");
if (n) {
/* fprintf(fout,"stubs \n\n"); */
for (i = 1; i <= n; i++) {
uname = getstr(LIBFILE, "lib-unit-name");
aisname = getstr(LIBFILE, "lib-ais-name");
parent = getnum(LIBFILE, "lib-parent");
cur_level = getnum(LIBFILE, "lib-cur-level");
m = getnum(LIBFILE, "stub-file-size");
for (j = 1; j <= m; j++)
ignore = getnum(LIBFILE, "stub-file");
/* fprintf(fout,"Stub %s\n", formatted_stub(uname)); */
}
/* fprintf(fout,"\n"); */
}
fclose(fout);
ifclose(LIBFILE);
return;
#ifdef TBSL
n = getnum(LIBFILE, "precedes-map-size");
printf("precedes map\n");
for (i = 1; i <= n; i += 2) {
dom = getnum(LIBFILE, "precedes-map-dom");
m = getnum(LIBFILE, "precedes-map-nelt");
printf(" %4d:", dom);
for (j = 1; j <= m; j++) {
range = getnum(LIBFILE, "precedes-map-ent");
printf(" %4d", range);
}
printf("\n");
}
n = getnum(LIBFILE, "compilation_table_size");
if (n) {
printf("\ncompilation table\n");
for (i = 1; i <= n; i++) {
unum = (int) getnum(LIBFILE, "compilation-table-ent");
printf(" %d\n", unum);
}
printf("\n");
}
/* late_instances */
n = getnum(LIBFILE, "late-instances-size");
if (n) {
printf("late instances\n");
for (i = 1; i <= n; i++) {
str = (char *) getstr(LIBFILE, "late-instances-str");
printf(" %s\n", str);
}
}
/* current code segment */
n = getnum(LIBFILE, "unit-size");
printf("\ncurrent code segments\n");
printf(" unit cs\n");
for (i = 1; i <= n; i++) {
cs = getnum(LIBFILE, "current-code-segment");
if (cs) printf(" %d: %d\n", i, cs);
}
/* local reference maps */
n = getnum(LIBFILE, "unit-size");
get_local_ref_maps(LIBFILE, n);
cde_pos = get_cde_slots(LIBFILE, axq);
/* could free axq_data_slots, etc., but keep for now */
/* read out LIB_STUB map (always empty for now) */
ifclose(LIBFILE);
return;
#endif
}
static void get_local_ref_maps(IFILE *ifile, int units) /*;get_local_ref_map*/
{
int unit, defined, i, off, n;
int sym_seq, sym_unit;
printf("\nlocal reference maps\n");
for (unit = 1; unit <= units; unit++) {
/* ignore empty ref maps (predef units) and obselete units */
defined = getnum(ifile, "local-ref-map-defined");
if (!defined) continue;
printf("%d: ", unit);
n = getnum(ifile, "local-ref-map-size");
n = n/2;
for (i = 1; i <= n; i++) {
sym_seq = getnum(ifile, "local-ref-map-sym-seq");
sym_unit = getnum(ifile, "local-ref-map-sym-unit");